<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>定时任务管理平台</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
    <link href="{{ url_for('static', filename='css/style.css') }}" rel="stylesheet">
    {% block head %}{% endblock %}
    <style>
        /* 主题切换相关样式 */
        :root {
            --bg-primary: #ffffff;
            --bg-secondary: #f8f9fa;
            --text-primary: #2c3e50;
            --text-secondary: #6c757d;
            --border-color: #e9ecef;
            --card-bg: #ffffff;
            --navbar-bg: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
            --primary-color: #3498db;
            --primary-hover: #2980b9;
            --accent-color: #ecf0f1;
        }
        
        [data-theme="dark"] {
            --bg-primary: #1a1a1a;
            --bg-secondary: #2d2d2d;
            --text-primary: #ecf0f1;
            --text-secondary: #bdc3c7;
            --border-color: #34495e;
            --card-bg: #2d2d2d;
            --navbar-bg: linear-gradient(135deg, #2c3e50 0%, #34495e 100%);
            --primary-color: #3498db;
            --primary-hover: #2980b9;
            --accent-color: #34495e;
        }
        
        /* 液态玻璃效果全局样式 */
        body {
            transition: background-color 0.3s ease, color 0.3s ease;
        }
        
        /* 液态玻璃效果主题切换按钮 */
        #theme-toggle {
            border: 1px solid rgba(0, 0, 0, 0.2);
            background: rgba(255, 255, 255, 0.2);
            color: #2c3e50;
            padding: 0.5rem;
            width: 38px;
            height: 38px;
            border-radius: 50%;
            display: flex;
            align-items: center;
            justify-content: center;
            transition: all 0.3s ease;
            backdrop-filter: blur(10px);
            margin: 0 0.5rem;
            position: relative;
            top: 0;
        }
        
        #theme-toggle:hover {
            background: rgba(255, 255, 255, 0.3);
            border-color: rgba(0, 0, 0, 0.3);
            transform: scale(1.05);
        }
        
        #theme-toggle:active {
            transform: scale(0.95);
        }
        
        #theme-toggle i {
            font-size: 0.9rem;
            transition: transform 0.3s ease;
            color: #2c3e50;
        }
        
        /* 暗色主题下的按钮样式调整 */
        [data-theme="dark"] #theme-toggle {
            border-color: rgba(255, 255, 255, 0.15);
            background: rgba(255, 255, 255, 0.05);
            color: #ffffff;
        }
        
        [data-theme="dark"] #theme-toggle:hover {
            background: rgba(255, 255, 255, 0.1);
            border-color: rgba(255, 255, 255, 0.25);
        }
        
        [data-theme="dark"] #theme-toggle i {
            color: #ffffff;
        }
        a.navbar-brand, a.navbar-brand:hover, a.navbar-brand:focus,
        .navbar-brand, .navbar-brand:hover, .navbar-brand:focus {
            text-decoration: none !important;
            box-shadow: none !important;
            color: #333333 !important;
        }
        
        .navbar-brand:hover {
            color: #000000 !important;
        }
        
        /* 确保品牌文字内的所有元素都跟随主题 */
        .navbar-brand span,
        .navbar-brand i {
            color: inherit !important;
        }
        
        .navbar-brand:hover span,
        .navbar-brand:hover i {
            color: inherit !important;
        }
        
        /* 暗色主题下的品牌文字 */
        [data-theme="dark"] .navbar-brand,
        [data-theme="dark"] .navbar-brand:hover,
        [data-theme="dark"] .navbar-brand:focus {
            color: #ffffff !important;
        }
        
        [data-theme="dark"] .navbar-brand:hover {
            color: #ffffff !important;
        }
        .navbar {
            position: fixed !important;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            z-index: 1030;
            margin: 0 !important;
            /* 椭圆形透镜形状 */
            width: 95vw;
            max-width: 1400px;
            height: 80px;
            border-radius: 40px;
            /* 基础样式 */
            background: transparent !important;
            backdrop-filter: blur(4px) !important;
            -webkit-backdrop-filter: blur(4px) !important;
            box-shadow: 0 6px 6px rgba(0, 0, 0, 0.2), 0 0 20px rgba(0, 0, 0, 0.1) !important;
            border: 1px solid rgba(255, 255, 255, 0.3) !important;
            overflow: visible !important;
        }
        [data-theme="dark"] .navbar {
            background: transparent !important;
            backdrop-filter: blur(4px) !important;
            -webkit-backdrop-filter: blur(4px) !important;
            box-shadow: 0 6px 6px rgba(0, 0, 0, 0.3), 0 0 20px rgba(0, 0, 0, 0.2) !important;
            border: 1px solid rgba(255, 255, 255, 0.1) !important;
        }
        
        /* 液态玻璃背景层 */
        .navbar-bg-liquid {
            position: absolute;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            background: rgba(255, 255, 255, 0.1);
            filter: url(#lg-dist);
            backdrop-filter: blur(8px) saturate(120%);
            isolation: isolate;
            z-index: -1;
            border-radius: inherit;
        }
        
        [data-theme="dark"] .navbar-bg-liquid {
            background: rgba(0, 0, 0, 0.1);
        }
        
        /* 导航栏菜单按钮样式 - 全透明无模糊 */
        .navbar-nav .nav-link {
            color: #333333 !important;
            font-weight: 500;
            padding: 0.75rem 1rem;
            border-radius: 12px;
            transition: all 0.3s ease;
            background: transparent !important;
            border: none !important;
            backdrop-filter: none !important;
        }
        
        .navbar-nav .nav-link:hover {
            color: #000000 !important;
            background: transparent !important;
            transform: translateY(-1px);
        }
        
        .navbar-nav .nav-link:focus {
            color: #000000 !important;
            background: transparent !important;
            box-shadow: none !important;
        }
        
        .navbar-nav .nav-link.active {
            color: #000000 !important;
            background: transparent !important;
        }
        
        /* 暗色主题下的导航链接 */
        [data-theme="dark"] .navbar-nav .nav-link {
            color: #ffffff !important;
        }
        
        [data-theme="dark"] .navbar-nav .nav-link:hover {
            color: #ffffff !important;
        }
        
        [data-theme="dark"] .navbar-nav .nav-link:focus {
            color: #ffffff !important;
        }
        
        [data-theme="dark"] .navbar-nav .nav-link.active {
            color: #ffffff !important;
        }
        
        /* 确保下拉菜单文字颜色正确 */
        .dropdown-item {
            color: #333 !important;
            transition: all 0.3s ease;
        }
        
        .dropdown-item:hover {
            color: #000 !important;
            background: rgba(0, 0, 0, 0.05) !important;
        }
        
        /* 下拉菜单样式 */
        .dropdown-menu {
            background: transparent;
            backdrop-filter: none;
            border: 1px solid rgba(255, 255, 255, 0.3);
            border-radius: 12px;
            box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
            position: absolute !important;
            top: 100% !important;
            left: 0 !important;
            z-index: 1050 !important;
            margin-top: 20px !important;
            min-width: 200px !important;
        }
        
        [data-theme="dark"] .dropdown-menu {
            background: transparent;
            border: 1px solid rgba(255, 255, 255, 0.2);
        }
        
        /* 确保下拉菜单容器不受导航栏overflow限制 */
        .dropdown {
            position: static !important;
        }
        
        .nav-item.dropdown {
            position: relative !important;
        }
        body {
            padding-top: 120px;
        }
        @media (max-width: 991.98px) {
            body {
                padding-top: 110px;
            }
        }
        

    </style>
</head>
<body>
    <!-- 现代化导航栏 -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-gradient">
        <!-- 液态玻璃背景层 -->
        <div class="navbar-bg-liquid"></div>
        
        <div class="container d-flex align-items-center">
            <a class="navbar-brand d-flex align-items-center" href="{{ url_for('dashboard') }}">
                <i class="fas fa-clock me-2"></i>
                <span class="fw-bold">定时任务管理平台</span>
            </a>
            
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    {% if current_user.has_permission('dingtalk') %}
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle d-flex align-items-center" href="#" role="button" data-bs-toggle="dropdown">
                            <i class="fas fa-tasks me-1"></i>
                            <span>钉钉消息任务管理</span>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" href="{{ url_for('dashboard') }}">
                                <i class="fas fa-chart-line me-2"></i>仪表板
                            </a></li>
                            <li><hr class="dropdown-divider"></li>
                            <li><a class="dropdown-item" href="{{ url_for('robot_management') }}">
                                <i class="fas fa-robot me-2"></i>机器人管理
                            </a></li>
                            <li><a class="dropdown-item" href="{{ url_for('script_management') }}">
                                <i class="fas fa-code me-2"></i>脚本管理
                            </a></li>
                            <li><a class="dropdown-item" href="{{ url_for('scheduled_tasks') }}">
                                <i class="fas fa-clock me-2"></i>定时任务
                            </a></li>
                        </ul>
                    </li>
                    {% endif %}
                    
                    {% if current_user.has_permission('custom_tasks') %}
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle d-flex align-items-center" href="#" role="button" data-bs-toggle="dropdown">
                            <i class="fas fa-puzzle-piece me-1"></i>
                            <span>用户自定义定时任务</span>
                        </a>
                        <ul class="dropdown-menu">
                            <li><a class="dropdown-item" href="{{ url_for('extended_dashboard') }}">
                                <i class="fas fa-chart-line me-2"></i>仪表板
                            </a></li>
                            <li><hr class="dropdown-divider"></li>
                            <li><a class="dropdown-item" href="{{ url_for('extended_tasks') }}">
                                <i class="fas fa-clock me-2"></i>定时任务管理
                            </a></li>
                            <li><a class="dropdown-item" href="{{ url_for('extended_scripts') }}">
                                <i class="fas fa-code me-2"></i>脚本管理
                            </a></li>
                            <li><a class="dropdown-item" href="{{ url_for('file_management') }}">
                                <i class="fas fa-folder-open me-2"></i>文件管理
                            </a></li>
                        </ul>
                    </li>
                    {% endif %}
                    
                    {% if current_user.has_permission('packages') %}
                    <li class="nav-item">
                        <a class="nav-link d-flex align-items-center" href="{{ url_for('package_management') }}">
                            <i class="fas fa-boxes me-1"></i>
                            <span>依赖项管理</span>
                        </a>
                    </li>
                    {% endif %}
                    
                    <li class="nav-item">
                        <a class="nav-link d-flex align-items-center" href="{{ url_for('system_monitor_page') }}">
                            <i class="fas fa-chart-line me-1"></i>
                            <span>系统监控</span>
                        </a>
                    </li>
                    
                    {% if current_user.has_permission('users') %}
                    <li class="nav-item">
                        <a class="nav-link d-flex align-items-center" href="{{ url_for('user_management') }}">
                            <i class="fas fa-users me-1"></i>
                            <span>用户管理</span>
                        </a>
                    </li>
                    {% endif %}
                    <li class="nav-item">
                        <a class="nav-link d-flex align-items-center" href="{{ url_for('about_project') }}">
                            <i class="fas fa-info-circle me-1"></i>
                            <span>关于项目</span>
                        </a>
                    </li>
                </ul>
                
                <ul class="navbar-nav d-flex align-items-center">
                    <!-- 主题切换按钮 -->
                    <li class="nav-item d-flex align-items-center">
                        <button id="theme-toggle" title="切换主题">
                            <i id="theme-icon" class="fas fa-moon"></i>
                        </button>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle d-flex align-items-center" href="#" role="button" data-bs-toggle="dropdown">
                            <i class="fas fa-user-circle me-1"></i>
                            <span>{{ current_user.username }}</span>
                        </a>
                        <ul class="dropdown-menu dropdown-menu-end">
                            <li><a class="dropdown-item" href="{{ url_for('dashboard') }}">
                                <i class="fas fa-home me-2"></i>首页
                            </a></li>
                            <li><hr class="dropdown-divider"></li>
                            <li><a class="dropdown-item" href="{{ url_for('custom_parameters_page') }}">
                                <i class="fas fa-cogs me-2"></i>自定义参数
                            </a></li>
                            <li><a class="dropdown-item" href="{{ url_for('change_password') }}">
                                <i class="fas fa-key me-2"></i>修改密码
                            </a></li>
                            <li><hr class="dropdown-divider"></li>
                            <li><a class="dropdown-item text-danger" href="{{ url_for('logout') }}">
                                <i class="fas fa-sign-out-alt me-2"></i>退出登录
                            </a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- 创建液态滤镜 -->
    <svg style="display: none">
        <defs>
            <!-- 液态玻璃滤镜 - 基于liquid-glass-react -->
            <filter id="lg-dist" x="-35%" y="-35%" width="170%" height="170%" colorInterpolationFilters="sRGB">
                <!-- 使用预生成的位移映射图像 -->
                <feImage id="feimage" x="0" y="0" width="100%" height="100%" result="DISPLACEMENT_MAP" href="" preserveAspectRatio="xMidYMid slice" />

                <!-- 创建边缘遮罩 -->
                <feColorMatrix
                    in="DISPLACEMENT_MAP"
                    type="matrix"
                    values="0.3 0.3 0.3 0 0
                            0.3 0.3 0.3 0 0
                            0.3 0.3 0.3 0 0
                            0 0 0 1 0"
                    result="EDGE_INTENSITY"
                />
                <feComponentTransfer in="EDGE_INTENSITY" result="EDGE_MASK">
                    <feFuncA type="discrete" tableValues="0 0.1 1"/>
                </feComponentTransfer>

                <!-- 原始图像用于中心 -->
                <feOffset in="SourceGraphic" dx="0" dy="0" result="CENTER_ORIGINAL"/>

                <!-- 红色通道位移 -->
                <feDisplacementMap in="SourceGraphic" in2="DISPLACEMENT_MAP" scale="70" xChannelSelector="R" yChannelSelector="B" result="RED_DISPLACED"/>
                <feColorMatrix
                    in="RED_DISPLACED"
                    type="matrix"
                    values="1 0 0 0 0
                            0 0 0 0 0
                            0 0 0 0 0
                            0 0 0 1 0"
                    result="RED_CHANNEL"
                />

                <!-- 绿色通道位移 -->
                <feDisplacementMap in="SourceGraphic" in2="DISPLACEMENT_MAP" scale="65" xChannelSelector="R" yChannelSelector="B" result="GREEN_DISPLACED"/>
                <feColorMatrix
                    in="GREEN_DISPLACED"
                    type="matrix"
                    values="0 0 0 0 0
                            0 1 0 0 0
                            0 0 0 0 0
                            0 0 0 1 0"
                    result="GREEN_CHANNEL"
                />

                <!-- 蓝色通道位移 -->
                <feDisplacementMap in="SourceGraphic" in2="DISPLACEMENT_MAP" scale="60" xChannelSelector="R" yChannelSelector="B" result="BLUE_DISPLACED"/>
                <feColorMatrix
                    in="BLUE_DISPLACED"
                    type="matrix"
                    values="0 0 0 0 0
                            0 0 0 0 0
                            0 0 1 0 0
                            0 0 0 1 0"
                    result="BLUE_CHANNEL"
                />

                <!-- 合并所有通道实现色差 -->
                <feBlend in="GREEN_CHANNEL" in2="BLUE_CHANNEL" mode="screen" result="GB_COMBINED"/>
                <feBlend in="RED_CHANNEL" in2="GB_COMBINED" mode="screen" result="RGB_COMBINED"/>

                <!-- 轻微模糊软化色差效果 -->
                <feGaussianBlur in="RGB_COMBINED" stdDeviation="0.3" result="ABERRATED_BLURRED"/>

                <!-- 应用边缘遮罩到色差效果 -->
                <feComposite in="ABERRATED_BLURRED" in2="EDGE_MASK" operator="in" result="EDGE_ABERRATION"/>

                <!-- 创建中心遮罩 -->
                <feComponentTransfer in="EDGE_MASK" result="INVERTED_MASK">
                    <feFuncA type="table" tableValues="1 0"/>
                </feComponentTransfer>
                <feComposite in="CENTER_ORIGINAL" in2="INVERTED_MASK" operator="in" result="CENTER_CLEAN"/>

                <!-- 合并边缘色差和清晰中心 -->
                <feComposite in="EDGE_ABERRATION" in2="CENTER_CLEAN" operator="over"/>
            </filter>
        </defs>
    </svg>

    <!-- 主要内容区域 -->
    <main class="main-content">
        <div class="container-fluid">
            <!-- 消息提示 -->
            {% with messages = get_flashed_messages(with_categories=true) %}
                {% if messages %}
                    <div class="messages-container">
                        {% for category, message in messages %}
                            <div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
                                <i class="fas fa-{{ 'check-circle' if category == 'success' else 'exclamation-triangle' if category == 'warning' else 'info-circle' if category == 'info' else 'times-circle' }} me-2"></i>
                                {{ message }}
                                <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                            </div>
                        {% endfor %}
                    </div>
                {% endif %}
            {% endwith %}
            
            <!-- 页面内容 -->
            {% block content %}{% endblock %}
        </div>
    </main>

    <!-- 页脚 -->
    <footer class="footer mt-auto py-3">
        <div class="container text-center">
            <span class="text-muted">© 2025 玄月十七(xuboyang) | Scheduled Task Management Platform</span>
        </div>
    </footer>

    <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
    <script>
    // 主题切换功能
    document.addEventListener('DOMContentLoaded', function() {
        const themeToggle = document.getElementById('theme-toggle');
        const themeIcon = document.getElementById('theme-icon');
        const body = document.body;
        
        // 从localStorage获取保存的主题
        const savedTheme = localStorage.getItem('theme') || 'light';
        
        // 应用保存的主题
        function applyTheme(theme) {
            if (theme === 'dark') {
                body.setAttribute('data-theme', 'dark');
                themeIcon.className = 'fas fa-sun';
                themeToggle.title = '切换到亮色主题';
            } else {
                body.removeAttribute('data-theme');
                themeIcon.className = 'fas fa-moon';
                themeToggle.title = '切换到暗色主题';
            }
        }
        
        // 初始化主题
        applyTheme(savedTheme);
        
        // 主题切换事件
        themeToggle.addEventListener('click', function() {
            const currentTheme = body.getAttribute('data-theme') === 'dark' ? 'dark' : 'light';
            const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
            
            // 应用新主题
            applyTheme(newTheme);
            
            // 保存到localStorage
            localStorage.setItem('theme', newTheme);
            
            // 添加切换动画效果
            themeToggle.style.transform = 'rotate(180deg)';
            setTimeout(() => {
                themeToggle.style.transform = 'rotate(0deg)';
            }, 300);
        });
        
        // 确保下拉菜单正常工作
        console.log('页面加载完成，主题切换和下拉菜单应该正常工作');
    });
    </script>
    {% block scripts %}{% endblock %}
</body>
</html>